/*
 * @Author: byron
 * @Date: 2021-09-18 19:01:25
 * @LastEditTime: 2021-09-18 19:17:43
 */
const proxy = require("http-proxy-middleware");

module.exports = function (app) {
  app.use(
    proxy("/api1", {
      // 遇见/api1前缀的请求，就会触发该代理配置
      target: "http://localhost:5000", //请求转发给谁
      changeOrigin: true, // 控制服务器收到的响应头中Host字段
      pathRewrite: { "^/api1": "" }, // 重写url 更换/api1 (正则匹配)
    })
  );
  app.use(
    proxy("/api2", {
      target: "http://localhost:5001",
      changeOrigin: true,
      pathRewrite: { "^/api2": "" },
    })
  );
};
